Add new parameter "preset" for ggsave() to specify width/height at once#2781
Closed
ilarischeinin wants to merge 3 commits intotidyverse:masterfrom
Closed
Add new parameter "preset" for ggsave() to specify width/height at once#2781ilarischeinin wants to merge 3 commits intotidyverse:masterfrom
ilarischeinin wants to merge 3 commits intotidyverse:masterfrom
Conversation
Presets can be used to specify plot width and height (and units) at
once. It recognizes common paper sizes (such as "a4" and "letter"),
common screen resolutions ("4k"), or a resolution specification such
as "1920x1080". All presets default to landscape orientation, and
portrait can be specified by appending an "r" (for rotated) to the end
of the string. This is similar to the "paper" option for
grDevices::pdf(), but with landscape being the default as it's
probably a more common choice for plots.
Member
|
@hadley, can you comment on whether you'd want this in ggplot2? If you do, I'll give it a proper review |
Member
|
This doesn't feel quite right for ggplot2 to me. It's a bit too big of a change to a very old function, and updating the preset list over time seems likely to add to the maintenance burden. |
Member
|
Agreed. |
|
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new parameter
presetforggsave()that allows plot width and height (and units) to be specified at once. It recognizes common paper sizes (such as "a4" and "letter"), common screen resolutions ("4k"), and resolution specifications such as "1920x1080".All presets default to landscape orientation, and portrait can be specified by appending an "r" (for rotated) to the end of the string. This is similar to the
paperoption forgrDevices::pdf(), but with landscape being the default as it's probably a more common choice for plots.(Naturally this new parameter could also be called
paperinstead ofpreset, but 1) that felt a bit too old-fashioned, and 2) might seem odd when making a plot that is to be placed on a sheet of paper together with other elements like text.sizeis another name I considered, but as the function already has a parameter calledlimitsize, I think they would be an odd pair. Anyways,presetis just one suggestion and I can rename it as wished.)For now, some selected paper sizes and screen resolutions are included, but I'm happy to make the list more comprehensive if that seems reasonable.
Example Usage